﻿//创建时间: 2010-10-19
//创建作者: 李晓忠
//功能说明: CMS系统 结点信息分类管理 
//最后修改: 2010-10-19
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;


namespace TRPOP.CMS.Web.Admin
{
    public partial class NodeContentSort_save : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.Node_Save;
        }
        #endregion

        #region 页面变量
        protected string m_strTitle = "结点信息分类管理";
        NodeContentSortManage oNodeContentSortManage = new NodeContentSortManage();
        protected bool m_IsAdd = true;
        protected int m_intId = 0;
        protected int m_intNId = 0;
        protected string m_strNodeName = "";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_intId = RequestHelper.RequestInt("id");
            m_intNId = RequestHelper.RequestInt("nid");
            if (!IsPostBack)
            {
                LoadBase();
            }
        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            int intFormInputLimitTypeId = 0;
            int.TryParse(lbtn.CommandArgument, out intFormInputLimitTypeId);
            SubmitAlertDelete(oNodeContentSortManage.DeleteInfoById(intFormInputLimitTypeId));
            LoadBase();
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strMSG = "名称 、Key";
            if (!PageAssist.CheckForm(txtName, ref strMSG) ||
                !PageAssist.CheckForm(txtKeyWord, ref strMSG)
                )
            {
                Alert(strMSG);
                return;
            }
            NodeContentSortInfo oNodeContentSortInfo = (NodeContentSortInfo)GetPageViewState("model");
            oNodeContentSortInfo.KeyWord = txtKeyWord.TextTrim.RemoveHtml();
            oNodeContentSortInfo.Name = txtName.TextTrim.RemoveHtml();
            oNodeContentSortInfo.Description = txtDescription.TextTrim.RemoveHtml();
            oNodeContentSortInfo.AddUserId = base.mUserBaseInfo.UserBaseId;
            oNodeContentSortInfo.AddTime = GetAdminAddTime;
            SubmitAlertAndParReset(oNodeContentSortManage.Save(oNodeContentSortInfo));

        }
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            NodeInfo oNodeInfo = null;
            NodeContentSortInfo oNodeContentSortInfo = null;
            if (m_intId > 0)
            {
                m_IsAdd = false;
                oNodeContentSortInfo = oNodeContentSortManage.GetInfoById(m_intId);
                if (oNodeContentSortInfo != null)
                {
                    InitPageViewState("model", oNodeContentSortInfo);
                    txtDescription.Text = oNodeContentSortInfo.Description;
                    txtKeyWord.Text = oNodeContentSortInfo.KeyWord;
                    txtName.Text = oNodeContentSortInfo.Name;
                    oNodeInfo = (new NodeManage()).GetInfoById(oNodeContentSortInfo.NodeId);

                }
            }
            else if (m_intNId > 0)
            {
                m_IsAdd = true;
                oNodeInfo = (new NodeManage()).GetInfoById(m_intNId);
                oNodeContentSortInfo = new NodeContentSortInfo();
                oNodeContentSortInfo.NodeId = m_intNId;               
                InitPageViewState("model", oNodeContentSortInfo);

            }
            if (oNodeInfo == null)
            {
                throw new Exception("结点不存在了");
            }
            else
            {
                m_strNodeName = oNodeInfo.Name;
            }

        }
        #endregion
    }
}
